﻿using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.Common;

namespace Chenxin.Lib.Business.DAL
{
    /// <summary>
    /// 数据访问类t_Contract_BaseInfo。
    /// </summary>
    public class t_Contract_BaseInfo
    {
        public t_Contract_BaseInfo()
        { }
        #region  成员方法

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public static bool Exists(Guid ContractId)
        {
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from t_Contract_BaseInfo where ContractId=@ContractId ");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ContractId", DbType.Guid, ContractId);
            int cmdresult;
            object obj = db.ExecuteScalar(dbCommand);
            if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
            {
                cmdresult = 0;
            }
            else
            {
                cmdresult = int.Parse(obj.ToString());
            }
            if (cmdresult == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static void Add(Chenxin.Lib.Business.Entity.t_Contract_BaseInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into t_Contract_BaseInfo(");

            strSql.Append("ContractId,ApplyId,ContractCode,ContractDate,BusinessDescribe,BusinessType,BargainType,BargainUnitPrice,BargainPrice,HouseId,HouseCode,HouseAddress,Area,CompleteYear,Fitment,CommunityId,Community,CommunityAddress,PropertyCode,Region,Block,CurrentFloor,TotalFloor,BuildingType,HouseUse,HouseType,BargainCityId,BargainCityName,BargainCompanyId,BargainCompanyName,BargainDepartmentId,BargainDepartmentName,BargainUserId,BargainUserName,VenderCityId,VenderCityName,VenderCompanyId,VenderCompanyName,VenderDepartId,VenderDepartName,VenderUserId,VenderUserName,VenderId,VenderName,VenderNo,VenderPhone,VenderMobile,BuyerCityId,BuyerCityName,BuyerCompanyId,BuyerCompanyName,BuyerDepartId,BuyerDepartName,BuyerUserId,BuyerUserName,BuyerId,BuyerName,BuyerNo,BuyerPhone,BuyerMobile,VStanCommision,BStanCommision,VRealCommision,BRealCommision,VCommision,BCommision,VConsulting,BConsulting,AppEmployeeId,AppEmployee,AppDepartId,AppDepart,AppCompanyId,AppCompany,AppCityId,AppCity,ConfirmEmplyeeId,ConfirmEmplyee,ConfirmDepartId,ConfirmDepart,ConfirmCompanyId,ConfirmCompany,ConfirmCityId,ConfirmCity,AddTime,UpdateCityId,UpdateCityName,UpdateCompanyId,UpdateCompanyName,UpdateDepartmentId,UpdateDepartmentName,UpdateUserId,UpdateUserName,UpdateTime,bArchivement,ArchivementDate,ArchivementYear,ArchivementMonth,LastCreateArchDate,CreateArchEmpId,CreateArchEmp,CreateArchDepartId,CreateArchDepart,LockStatus,Status,PointRemark,ContractCityId,ContractCityName,ContractCompanyId,ContractCompanyName,ContractDepartmentId,ContractDepartmentName,ContractUserId,ContractUserName,LitigationStatus,HasFollow,HouseProperty,CustomerSource,VSTDiscount,BSTDiscount,STMemo,FixDiscount,DiscountRate,RateDate,HasOver,OverName,OverTime)");

            strSql.Append(" values (");
            strSql.Append("@ContractId,@ApplyId,@ContractCode,@ContractDate,@BusinessDescribe,@BusinessType,@BargainType,@BargainUnitPrice,@BargainPrice,@HouseId,@HouseCode,@HouseAddress,@Area,@CompleteYear,@Fitment,@CommunityId,@Community,@CommunityAddress,@PropertyCode,@Region,@Block,@CurrentFloor,@TotalFloor,@BuildingType,@HouseUse,@HouseType,@BargainCityId,@BargainCityName,@BargainCompanyId,@BargainCompanyName,@BargainDepartmentId,@BargainDepartmentName,@BargainUserId,@BargainUserName,@VenderCityId,@VenderCityName,@VenderCompanyId,@VenderCompanyName,@VenderDepartId,@VenderDepartName,@VenderUserId,@VenderUserName,@VenderId,@VenderName,@VenderNo,@VenderPhone,@VenderMobile,@BuyerCityId,@BuyerCityName,@BuyerCompanyId,@BuyerCompanyName,@BuyerDepartId,@BuyerDepartName,@BuyerUserId,@BuyerUserName,@BuyerId,@BuyerName,@BuyerNo,@BuyerPhone,@BuyerMobile,@VStanCommision,@BStanCommision,@VRealCommision,@BRealCommision,@VCommision,@BCommision,@VConsulting,@BConsulting,@AppEmployeeId,@AppEmployee,@AppDepartId,@AppDepart,@AppCompanyId,@AppCompany,@AppCityId,@AppCity,@ConfirmEmplyeeId,@ConfirmEmplyee,@ConfirmDepartId,@ConfirmDepart,@ConfirmCompanyId,@ConfirmCompany,@ConfirmCityId,@ConfirmCity,@AddTime,@UpdateCityId,@UpdateCityName,@UpdateCompanyId,@UpdateCompanyName,@UpdateDepartmentId,@UpdateDepartmentName,@UpdateUserId,@UpdateUserName,@UpdateTime,@bArchivement,@ArchivementDate,@ArchivementYear,@ArchivementMonth,@LastCreateArchDate,@CreateArchEmpId,@CreateArchEmp,@CreateArchDepartId,@CreateArchDepart,@LockStatus,@Status,@PointRemark,@ContractCityId,@ContractCityName,@ContractCompanyId,@ContractCompanyName,@ContractDepartmentId,@ContractDepartmentName,@ContractUserId,@ContractUserName,@LitigationStatus,@HasFollow,@HouseProperty,@CustomerSource,@VSTDiscount,@BSTDiscount,@STMemo,@FixDiscount,@DiscountRate,@RateDate,@HasOver,@OverName,@OverTime)");
            /*
            strSql.Append("ContractId,ApplyId,ContractCode,ContractDate,BusinessDescribe,HouseProperty,BusinessType,BargainType,BargainUnitPrice,BargainPrice,HouseId,HouseCode,HouseAddress,Area,CompleteYear,Fitment,CommunityId,Community,CommunityAddress,PropertyCode,Region,Block,CurrentFloor,TotalFloor,BuildingType,HouseUse,HouseType,BargainCityId,BargainCityName,BargainCompanyId,BargainCompanyName,BargainDepartmentId,BargainDepartmentName,BargainUserId,BargainUserName,VenderCityId,VenderCityName,VenderCompanyId,VenderCompanyName,VenderDepartId,VenderDepartName,VenderUserId,VenderUserName,VenderId,VenderName,VenderNo,VenderPhone,VenderMobile,BuyerCityId,BuyerCityName,BuyerCompanyId,BuyerCompanyName,BuyerDepartId,BuyerDepartName,BuyerUserId,BuyerUserName,BuyerId,BuyerName,BuyerNo,BuyerPhone,BuyerMobile,VStanCommision,BStanCommision,VRealCommision,BRealCommision,VCommision,BCommision,VConsulting,BConsulting,AppEmployeeId,AppEmployee,AppDepartId,AppDepart,AppCompanyId,AppCompany,AppCityId,AppCity,ConfirmEmplyeeId,ConfirmEmplyee,ConfirmDepartId,ConfirmDepart,ConfirmCompanyId,ConfirmCompany,ConfirmCityId,ConfirmCity,AddTime,UpdateCityId,UpdateCityName,UpdateCompanyId,UpdateCompanyName,UpdateDepartmentId,UpdateDepartmentName,UpdateUserId,UpdateUserName,UpdateTime,bArchivement,ArchivementDate,ArchivementYear,ArchivementMonth,LastCreateArchDate,CreateArchEmpId,CreateArchEmp,CreateArchDepartId,CreateArchDepart,LockStatus,Status,PointRemark,ContractCityId,ContractCityName,ContractCompanyId,ContractCompanyName,ContractDepartmentId,ContractDepartmentName,ContractUserId,ContractUserName,LitigationStatus,HasFollow,Memo,bHasAdjust,CustomerSource,VSTDiscount,BSTDiscount,STMemo,FixDiscount,DiscountRate,RateDate,HasOver,OverName,OverTime)");

            strSql.Append(" values (");
            strSql.Append("@ContractId,@ApplyId,@ContractCode,@ContractDate,@BusinessDescribe,@HouseProperty,@BusinessType,@BargainType,@BargainUnitPrice,@BargainPrice,@HouseId,@HouseCode,@HouseAddress,@Area,@CompleteYear,@Fitment,@CommunityId,@Community,@CommunityAddress,@PropertyCode,@Region,@Block,@CurrentFloor,@TotalFloor,@BuildingType,@HouseUse,@HouseType,@BargainCityId,@BargainCityName,@BargainCompanyId,@BargainCompanyName,@BargainDepartmentId,@BargainDepartmentName,@BargainUserId,@BargainUserName,@VenderCityId,@VenderCityName,@VenderCompanyId,@VenderCompanyName,@VenderDepartId,@VenderDepartName,@VenderUserId,@VenderUserName,@VenderId,@VenderName,@VenderNo,@VenderPhone,@VenderMobile,@BuyerCityId,@BuyerCityName,@BuyerCompanyId,@BuyerCompanyName,@BuyerDepartId,@BuyerDepartName,@BuyerUserId,@BuyerUserName,@BuyerId,@BuyerName,@BuyerNo,@BuyerPhone,@BuyerMobile,@VStanCommision,@BStanCommision,@VRealCommision,@BRealCommision,@VCommision,@BCommision,@VConsulting,@BConsulting,@AppEmployeeId,@AppEmployee,@AppDepartId,@AppDepart,@AppCompanyId,@AppCompany,@AppCityId,@AppCity,@ConfirmEmplyeeId,@ConfirmEmplyee,@ConfirmDepartId,@ConfirmDepart,@ConfirmCompanyId,@ConfirmCompany,@ConfirmCityId,@ConfirmCity,@AddTime,@UpdateCityId,@UpdateCityName,@UpdateCompanyId,@UpdateCompanyName,@UpdateDepartmentId,@UpdateDepartmentName,@UpdateUserId,@UpdateUserName,@UpdateTime,@bArchivement,@ArchivementDate,@ArchivementYear,@ArchivementMonth,@LastCreateArchDate,@CreateArchEmpId,@CreateArchEmp,@CreateArchDepartId,@CreateArchDepart,@LockStatus,@Status,@PointRemark,@ContractCityId,@ContractCityName,@ContractCompanyId,@ContractCompanyName,@ContractDepartmentId,@ContractDepartmentName,@ContractUserId,@ContractUserName,@LitigationStatus,@HasFollow,@Memo,@bHasAdjust,@CustomerSource,@VSTDiscount,@BSTDiscount,@STMemo,@FixDiscount,@DiscountRate,@RateDate,@HasOver,@OverName,@OverTime)");
            */
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ContractId", DbType.Guid, model.ContractId);
            db.AddInParameter(dbCommand, "ApplyId", DbType.Guid, model.ApplyId);
            db.AddInParameter(dbCommand, "ContractCode", DbType.AnsiString, model.ContractCode);
            db.AddInParameter(dbCommand, "ContractDate", DbType.DateTime, model.ContractDate);
            db.AddInParameter(dbCommand, "BusinessDescribe", DbType.AnsiString, model.BusinessDescribe);
            db.AddInParameter(dbCommand, "BusinessType", DbType.Int32, model.BusinessType);
            db.AddInParameter(dbCommand, "HouseProperty", DbType.Int32, model.HouseProperty);
            db.AddInParameter(dbCommand, "BargainType", DbType.Int32, model.BargainType);
            db.AddInParameter(dbCommand, "BargainUnitPrice", DbType.Decimal, model.BargainUnitPrice);
            db.AddInParameter(dbCommand, "BargainPrice", DbType.Decimal, model.BargainPrice);
            db.AddInParameter(dbCommand, "HouseId", DbType.Guid, model.HouseId);
            db.AddInParameter(dbCommand, "HouseCode", DbType.AnsiString, model.HouseCode);
            db.AddInParameter(dbCommand, "HouseAddress", DbType.AnsiString, model.HouseAddress);
            db.AddInParameter(dbCommand, "Area", DbType.Decimal, model.Area);
            db.AddInParameter(dbCommand, "CommunityId", DbType.Guid, model.CommunityId);
            db.AddInParameter(dbCommand, "Community", DbType.AnsiString, model.Community);
            db.AddInParameter(dbCommand, "CommunityAddress", DbType.AnsiString, model.CommunityAddress);
            db.AddInParameter(dbCommand, "PropertyCode", DbType.AnsiString, model.PropertyCode);
            db.AddInParameter(dbCommand, "Region", DbType.AnsiString, model.Region);
            db.AddInParameter(dbCommand, "Block", DbType.AnsiString, model.Block);
            db.AddInParameter(dbCommand, "CurrentFloor", DbType.Int32, model.CurrentFloor);
            db.AddInParameter(dbCommand, "TotalFloor", DbType.Int32, model.TotalFloor);
            db.AddInParameter(dbCommand, "BuildingType", DbType.AnsiString, model.BuildingType);
            db.AddInParameter(dbCommand, "HouseUse", DbType.AnsiString, model.HouseUse);
            db.AddInParameter(dbCommand, "HouseType", DbType.AnsiString, model.HouseType);
            db.AddInParameter(dbCommand, "BargainCityId", DbType.Guid, model.BargainCityId);
            db.AddInParameter(dbCommand, "BargainCityName", DbType.AnsiString, model.BargainCityName);
            db.AddInParameter(dbCommand, "BargainCompanyId", DbType.Guid, model.BargainCompanyId);
            db.AddInParameter(dbCommand, "BargainCompanyName", DbType.AnsiString, model.BargainCompanyName);
            db.AddInParameter(dbCommand, "BargainDepartmentId", DbType.Guid, model.BargainDepartmentId);
            db.AddInParameter(dbCommand, "BargainDepartmentName", DbType.AnsiString, model.BargainDepartmentName);
            db.AddInParameter(dbCommand, "BargainUserId", DbType.Guid, model.BargainUserId);
            db.AddInParameter(dbCommand, "BargainUserName", DbType.AnsiString, model.BargainUserName);
            db.AddInParameter(dbCommand, "VenderCityId", DbType.Guid, model.VenderCityId);
            db.AddInParameter(dbCommand, "VenderCityName", DbType.AnsiString, model.VenderCityName);
            db.AddInParameter(dbCommand, "VenderCompanyId", DbType.Guid, model.VenderCompanyId);
            db.AddInParameter(dbCommand, "VenderCompanyName", DbType.AnsiString, model.VenderCompanyName);
            db.AddInParameter(dbCommand, "VenderDepartId", DbType.Guid, model.VenderDepartId);
            db.AddInParameter(dbCommand, "VenderDepartName", DbType.AnsiString, model.VenderDepartName);
            db.AddInParameter(dbCommand, "VenderUserId", DbType.Guid, model.VenderUserId);
            db.AddInParameter(dbCommand, "VenderUserName", DbType.AnsiString, model.VenderUserName);
            db.AddInParameter(dbCommand, "VenderId", DbType.Guid, model.VenderId);
            db.AddInParameter(dbCommand, "VenderName", DbType.AnsiString, model.VenderName);
            db.AddInParameter(dbCommand, "VenderNo", DbType.AnsiString, model.VenderNo);
            db.AddInParameter(dbCommand, "VenderPhone", DbType.AnsiString, model.VenderPhone);
            db.AddInParameter(dbCommand, "VenderMobile", DbType.AnsiString, model.VenderMobile);
            db.AddInParameter(dbCommand, "BuyerCityId", DbType.Guid, model.BuyerCityId);
            db.AddInParameter(dbCommand, "BuyerCityName", DbType.AnsiString, model.BuyerCityName);
            db.AddInParameter(dbCommand, "BuyerCompanyId", DbType.Guid, model.BuyerCompanyId);
            db.AddInParameter(dbCommand, "BuyerCompanyName", DbType.AnsiString, model.BuyerCompanyName);
            db.AddInParameter(dbCommand, "BuyerDepartId", DbType.Guid, model.BuyerDepartId);
            db.AddInParameter(dbCommand, "BuyerDepartName", DbType.AnsiString, model.BuyerDepartName);
            db.AddInParameter(dbCommand, "BuyerUserId", DbType.Guid, model.BuyerUserId);
            db.AddInParameter(dbCommand, "BuyerUserName", DbType.AnsiString, model.BuyerUserName);
            db.AddInParameter(dbCommand, "BuyerId", DbType.Guid, model.BuyerId);
            db.AddInParameter(dbCommand, "BuyerName", DbType.AnsiString, model.BuyerName);
            db.AddInParameter(dbCommand, "BuyerNo", DbType.AnsiString, model.BuyerNo);
            db.AddInParameter(dbCommand, "BuyerPhone", DbType.AnsiString, model.BuyerPhone);
            db.AddInParameter(dbCommand, "BuyerMobile", DbType.AnsiString, model.BuyerMobile);
            db.AddInParameter(dbCommand, "VStanCommision", DbType.Decimal, model.VStanCommision);
            db.AddInParameter(dbCommand, "BStanCommision", DbType.Decimal, model.BStanCommision);
            db.AddInParameter(dbCommand, "VRealCommision", DbType.Decimal, model.VRealCommision);
            db.AddInParameter(dbCommand, "BRealCommision", DbType.Decimal, model.BRealCommision);
            db.AddInParameter(dbCommand, "VCommision", DbType.Decimal, model.VCommision);
            db.AddInParameter(dbCommand, "BCommision", DbType.Decimal, model.BCommision);
            db.AddInParameter(dbCommand, "VConsulting", DbType.Decimal, model.VConsulting);
            db.AddInParameter(dbCommand, "BConsulting", DbType.Decimal, model.BConsulting);
            db.AddInParameter(dbCommand, "AppEmployeeId", DbType.Guid, model.AppEmployeeId);
            db.AddInParameter(dbCommand, "AppEmployee", DbType.AnsiString, model.AppEmployee);
            db.AddInParameter(dbCommand, "AppDepartId", DbType.Guid, model.AppDepartId);
            db.AddInParameter(dbCommand, "AppDepart", DbType.AnsiString, model.AppDepart);
            db.AddInParameter(dbCommand, "AppCompanyId", DbType.Guid, model.AppCompanyId);
            db.AddInParameter(dbCommand, "AppCompany", DbType.AnsiString, model.AppCompany);
            db.AddInParameter(dbCommand, "AppCityId", DbType.Guid, model.AppCityId);
            db.AddInParameter(dbCommand, "AppCity", DbType.AnsiString, model.AppCity);
            db.AddInParameter(dbCommand, "ConfirmEmplyeeId", DbType.Guid, model.ConfirmEmplyeeId);
            db.AddInParameter(dbCommand, "ConfirmEmplyee", DbType.AnsiString, model.ConfirmEmplyee);
            db.AddInParameter(dbCommand, "ConfirmDepartId", DbType.Guid, model.ConfirmDepartId);
            db.AddInParameter(dbCommand, "ConfirmDepart", DbType.AnsiString, model.ConfirmDepart);
            db.AddInParameter(dbCommand, "ConfirmCompanyId", DbType.Guid, model.ConfirmCompanyId);
            db.AddInParameter(dbCommand, "ConfirmCompany", DbType.AnsiString, model.ConfirmCompany);
            db.AddInParameter(dbCommand, "ConfirmCityId", DbType.Guid, model.ConfirmCityId);
            db.AddInParameter(dbCommand, "ConfirmCity", DbType.AnsiString, model.ConfirmCity);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, model.AddTime);
            db.AddInParameter(dbCommand, "UpdateCityId", DbType.Guid, model.UpdateCityId);
            db.AddInParameter(dbCommand, "UpdateCityName", DbType.AnsiString, model.UpdateCityName);
            db.AddInParameter(dbCommand, "UpdateCompanyId", DbType.Guid, model.UpdateCompanyId);
            db.AddInParameter(dbCommand, "UpdateCompanyName", DbType.AnsiString, model.UpdateCompanyName);
            db.AddInParameter(dbCommand, "UpdateDepartmentId", DbType.Guid, model.UpdateDepartmentId);
            db.AddInParameter(dbCommand, "UpdateDepartmentName", DbType.AnsiString, model.UpdateDepartmentName);
            db.AddInParameter(dbCommand, "UpdateUserId", DbType.Guid, model.UpdateUserId);
            db.AddInParameter(dbCommand, "UpdateUserName", DbType.AnsiString, model.UpdateUserName);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime, model.UpdateTime);
            db.AddInParameter(dbCommand, "bArchivement", DbType.Boolean, model.bArchivement);
            db.AddInParameter(dbCommand, "ArchivementDate", DbType.DateTime, model.ArchivementDate);
            db.AddInParameter(dbCommand, "ArchivementYear", DbType.Int32, model.ArchivementYear);
            db.AddInParameter(dbCommand, "ArchivementMonth", DbType.Int32, model.ArchivementMonth);
            db.AddInParameter(dbCommand, "LastCreateArchDate", DbType.DateTime, model.LastCreateArchDate);
            db.AddInParameter(dbCommand, "CreateArchEmpId", DbType.Guid, model.CreateArchEmpId);
            db.AddInParameter(dbCommand, "CreateArchEmp", DbType.AnsiString, model.CreateArchEmp);
            db.AddInParameter(dbCommand, "CreateArchDepartId", DbType.Guid, model.CreateArchDepartId);
            db.AddInParameter(dbCommand, "CreateArchDepart", DbType.AnsiString, model.CreateArchDepart);
            db.AddInParameter(dbCommand, "LockStatus", DbType.Int32, model.LockStatus);
            db.AddInParameter(dbCommand, "Status", DbType.Int32, model.Status);
            db.AddInParameter(dbCommand, "PointRemark", DbType.AnsiString, model.PointRemark);
            db.AddInParameter(dbCommand, "ContractCityId", DbType.Guid, model.ContractCityId);
            db.AddInParameter(dbCommand, "ContractCityName", DbType.AnsiString, model.ContractCityName);
            db.AddInParameter(dbCommand, "ContractCompanyId", DbType.Guid, model.ContractCompanyId);
            db.AddInParameter(dbCommand, "ContractCompanyName", DbType.AnsiString, model.ContractCompanyName);
            db.AddInParameter(dbCommand, "ContractDepartmentId", DbType.Guid, model.ContractDepartmentId);
            db.AddInParameter(dbCommand, "ContractDepartmentName", DbType.AnsiString, model.ContractDepartmentName);
            db.AddInParameter(dbCommand, "ContractUserId", DbType.Guid, model.ContractUserId);
            db.AddInParameter(dbCommand, "ContractUserName", DbType.AnsiString, model.ContractUserName);
            db.AddInParameter(dbCommand, "CompleteYear", DbType.AnsiString, model.CompleteYear);
            db.AddInParameter(dbCommand, "Fitment", DbType.AnsiString, model.Fitment);
            db.AddInParameter(dbCommand, "LitigationStatus", DbType.Int32, model.LitigationStatus);
            db.AddInParameter(dbCommand, "HasFollow", DbType.Boolean, model.HasFollow);
            //db.AddInParameter(dbCommand, "Memo", DbType.AnsiString, model.Memo);
            db.AddInParameter(dbCommand, "CustomerSource", DbType.AnsiString, model.CustomerSource);
            db.AddInParameter(dbCommand, "VSTDiscount", DbType.Decimal, model.VSTDiscount);
            db.AddInParameter(dbCommand, "BSTDiscount", DbType.Decimal, model.BSTDiscount);
            db.AddInParameter(dbCommand, "STMemo", DbType.AnsiString, model.STMemo);
            db.AddInParameter(dbCommand, "FixDiscount", DbType.Decimal, model.FixDiscount);
            db.AddInParameter(dbCommand, "DiscountRate", DbType.Decimal, model.DiscountRate);
            db.AddInParameter(dbCommand, "RateDate", DbType.DateTime, model.RateDate);
            db.AddInParameter(dbCommand, "HasOver", DbType.Boolean, model.HasOver);
            db.AddInParameter(dbCommand, "OverName", DbType.AnsiString, model.OverName);
            db.AddInParameter(dbCommand, "OverTime", DbType.DateTime, model.OverTime);
            db.ExecuteNonQuery(dbCommand);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static void Update(Chenxin.Lib.Business.Entity.t_Contract_BaseInfo model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update t_Contract_BaseInfo set ");
            strSql.Append("ApplyId=@ApplyId,");
            strSql.Append("ContractCode=@ContractCode,");
            strSql.Append("ContractDate=@ContractDate,");
            strSql.Append("BusinessDescribe=@BusinessDescribe,");
            strSql.Append("BusinessType=@BusinessType,");
            strSql.Append("BargainType=@BargainType,");
            strSql.Append("BargainUnitPrice=@BargainUnitPrice,");
            strSql.Append("BargainPrice=@BargainPrice,");
            strSql.Append("HouseId=@HouseId,");
            strSql.Append("HouseCode=@HouseCode,");
            strSql.Append("HouseAddress=@HouseAddress,");
            strSql.Append("Area=@Area,");
            strSql.Append("CompleteYear=@CompleteYear,");
            strSql.Append("Fitment=@Fitment,");
            strSql.Append("CommunityId=@CommunityId,");
            strSql.Append("Community=@Community,");
            strSql.Append("CommunityAddress=@CommunityAddress,");
            strSql.Append("PropertyCode=@PropertyCode,");
            strSql.Append("Region=@Region,");
            strSql.Append("Block=@Block,");
            strSql.Append("CurrentFloor=@CurrentFloor,");
            strSql.Append("TotalFloor=@TotalFloor,");
            strSql.Append("BuildingType=@BuildingType,");
            strSql.Append("HouseUse=@HouseUse,");
            strSql.Append("HouseType=@HouseType,");
            strSql.Append("BargainCityId=@BargainCityId,");
            strSql.Append("BargainCityName=@BargainCityName,");
            strSql.Append("BargainCompanyId=@BargainCompanyId,");
            strSql.Append("BargainCompanyName=@BargainCompanyName,");
            strSql.Append("BargainDepartmentId=@BargainDepartmentId,");
            strSql.Append("BargainDepartmentName=@BargainDepartmentName,");
            strSql.Append("BargainUserId=@BargainUserId,");
            strSql.Append("BargainUserName=@BargainUserName,");
            strSql.Append("VenderCityId=@VenderCityId,");
            strSql.Append("VenderCityName=@VenderCityName,");
            strSql.Append("VenderCompanyId=@VenderCompanyId,");
            strSql.Append("VenderCompanyName=@VenderCompanyName,");
            strSql.Append("VenderDepartId=@VenderDepartId,");
            strSql.Append("VenderDepartName=@VenderDepartName,");
            strSql.Append("VenderUserId=@VenderUserId,");
            strSql.Append("VenderUserName=@VenderUserName,");
            strSql.Append("VenderId=@VenderId,");
            strSql.Append("VenderName=@VenderName,");
            strSql.Append("VenderNo=@VenderNo,");
            strSql.Append("VenderPhone=@VenderPhone,");
            strSql.Append("VenderMobile=@VenderMobile,");
            strSql.Append("BuyerCityId=@BuyerCityId,");
            strSql.Append("BuyerCityName=@BuyerCityName,");
            strSql.Append("BuyerCompanyId=@BuyerCompanyId,");
            strSql.Append("BuyerCompanyName=@BuyerCompanyName,");
            strSql.Append("BuyerDepartId=@BuyerDepartId,");
            strSql.Append("BuyerDepartName=@BuyerDepartName,");
            strSql.Append("BuyerUserId=@BuyerUserId,");
            strSql.Append("BuyerUserName=@BuyerUserName,");
            strSql.Append("BuyerId=@BuyerId,");
            strSql.Append("BuyerName=@BuyerName,");
            strSql.Append("BuyerNo=@BuyerNo,");
            strSql.Append("BuyerPhone=@BuyerPhone,");
            strSql.Append("BuyerMobile=@BuyerMobile,");
            strSql.Append("VStanCommision=@VStanCommision,");
            strSql.Append("BStanCommision=@BStanCommision,");
            strSql.Append("VRealCommision=@VRealCommision,");
            strSql.Append("BRealCommision=@BRealCommision,");
            strSql.Append("VCommision=@VCommision,");
            strSql.Append("BCommision=@BCommision,");
            strSql.Append("VConsulting=@VConsulting,");
            strSql.Append("BConsulting=@BConsulting,");
            strSql.Append("AppEmployeeId=@AppEmployeeId,");
            strSql.Append("AppEmployee=@AppEmployee,");
            strSql.Append("AppDepartId=@AppDepartId,");
            strSql.Append("AppDepart=@AppDepart,");
            strSql.Append("AppCompanyId=@AppCompanyId,");
            strSql.Append("AppCompany=@AppCompany,");
            strSql.Append("AppCityId=@AppCityId,");
            strSql.Append("AppCity=@AppCity,");
            strSql.Append("ConfirmEmplyeeId=@ConfirmEmplyeeId,");
            strSql.Append("ConfirmEmplyee=@ConfirmEmplyee,");
            strSql.Append("ConfirmDepartId=@ConfirmDepartId,");
            strSql.Append("ConfirmDepart=@ConfirmDepart,");
            strSql.Append("ConfirmCompanyId=@ConfirmCompanyId,");
            strSql.Append("ConfirmCompany=@ConfirmCompany,");
            strSql.Append("ConfirmCityId=@ConfirmCityId,");
            strSql.Append("ConfirmCity=@ConfirmCity,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("UpdateCityId=@UpdateCityId,");
            strSql.Append("UpdateCityName=@UpdateCityName,");
            strSql.Append("UpdateCompanyId=@UpdateCompanyId,");
            strSql.Append("UpdateCompanyName=@UpdateCompanyName,");
            strSql.Append("UpdateDepartmentId=@UpdateDepartmentId,");
            strSql.Append("UpdateDepartmentName=@UpdateDepartmentName,");
            strSql.Append("UpdateUserId=@UpdateUserId,");
            strSql.Append("UpdateUserName=@UpdateUserName,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("bArchivement=@bArchivement,");
            strSql.Append("ArchivementDate=@ArchivementDate,");
            strSql.Append("ArchivementYear=@ArchivementYear,");
            strSql.Append("ArchivementMonth=@ArchivementMonth,");
            strSql.Append("LastCreateArchDate=@LastCreateArchDate,");
            strSql.Append("CreateArchEmpId=@CreateArchEmpId,");
            strSql.Append("CreateArchEmp=@CreateArchEmp,");
            strSql.Append("CreateArchDepartId=@CreateArchDepartId,");
            strSql.Append("CreateArchDepart=@CreateArchDepart,");
            strSql.Append("LockStatus=@LockStatus,");
            strSql.Append("Status=@Status,");
            strSql.Append("PointRemark=@PointRemark,");
            strSql.Append("ContractCityId=@ContractCityId,");
            strSql.Append("ContractCityName=@ContractCityName,");
            strSql.Append("ContractCompanyId=@ContractCompanyId,");
            strSql.Append("ContractCompanyName=@ContractCompanyName,");
            strSql.Append("ContractDepartmentId=@ContractDepartmentId,");
            strSql.Append("ContractDepartmentName=@ContractDepartmentName,");
            strSql.Append("ContractUserId=@ContractUserId,");
            strSql.Append("LitigationStatus=@LitigationStatus,");
            strSql.Append("HasFollow=@HasFollow,");
            strSql.Append("HouseProperty=@HouseProperty,");
            strSql.Append("ContractUserName=@ContractUserName,");
            strSql.Append("CustomerSource=@CustomerSource,");
            strSql.Append("VSTDiscount=@VSTDiscount,");
            strSql.Append("BSTDiscount=@BSTDiscount,");
            strSql.Append("STMemo=@STMemo,");
            strSql.Append("FixDiscount=@FixDiscount,");
            strSql.Append("DiscountRate=@DiscountRate,");
            strSql.Append("RateDate=@RateDate,");
            strSql.Append("HasOver=@HasOver,");
            strSql.Append("OverName=@OverName,");
            strSql.Append("OverTime=@OverTime");
            strSql.Append(" where ContractId=@ContractId ");
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ContractId", DbType.Guid, model.ContractId);
            db.AddInParameter(dbCommand, "ApplyId", DbType.Guid, model.ApplyId);
            db.AddInParameter(dbCommand, "ContractCode", DbType.AnsiString, model.ContractCode);
            db.AddInParameter(dbCommand, "ContractDate", DbType.DateTime, model.ContractDate);
            db.AddInParameter(dbCommand, "BusinessDescribe", DbType.AnsiString, model.BusinessDescribe);
            db.AddInParameter(dbCommand, "BusinessType", DbType.Int32, model.BusinessType);
            db.AddInParameter(dbCommand, "BargainType", DbType.Int32, model.BargainType);
            db.AddInParameter(dbCommand, "HouseProperty", DbType.Int32, model.HouseProperty);
            db.AddInParameter(dbCommand, "BargainUnitPrice", DbType.Decimal, model.BargainUnitPrice);
            db.AddInParameter(dbCommand, "BargainPrice", DbType.Decimal, model.BargainPrice);
            db.AddInParameter(dbCommand, "HouseId", DbType.Guid, model.HouseId);
            db.AddInParameter(dbCommand, "HouseCode", DbType.AnsiString, model.HouseCode);
            db.AddInParameter(dbCommand, "HouseAddress", DbType.AnsiString, model.HouseAddress);
            db.AddInParameter(dbCommand, "Area", DbType.Decimal, model.Area);
            db.AddInParameter(dbCommand, "CommunityId", DbType.Guid, model.CommunityId);
            db.AddInParameter(dbCommand, "Community", DbType.AnsiString, model.Community);
            db.AddInParameter(dbCommand, "CommunityAddress", DbType.AnsiString, model.CommunityAddress);
            db.AddInParameter(dbCommand, "PropertyCode", DbType.AnsiString, model.PropertyCode);
            db.AddInParameter(dbCommand, "Region", DbType.AnsiString, model.Region);
            db.AddInParameter(dbCommand, "Block", DbType.AnsiString, model.Block);
            db.AddInParameter(dbCommand, "CurrentFloor", DbType.Int32, model.CurrentFloor);
            db.AddInParameter(dbCommand, "TotalFloor", DbType.Int32, model.TotalFloor);
            db.AddInParameter(dbCommand, "BuildingType", DbType.AnsiString, model.BuildingType);
            db.AddInParameter(dbCommand, "HouseUse", DbType.AnsiString, model.HouseUse);
            db.AddInParameter(dbCommand, "HouseType", DbType.AnsiString, model.HouseType);
            db.AddInParameter(dbCommand, "BargainCityId", DbType.Guid, model.BargainCityId);
            db.AddInParameter(dbCommand, "BargainCityName", DbType.AnsiString, model.BargainCityName);
            db.AddInParameter(dbCommand, "BargainCompanyId", DbType.Guid, model.BargainCompanyId);
            db.AddInParameter(dbCommand, "BargainCompanyName", DbType.AnsiString, model.BargainCompanyName);
            db.AddInParameter(dbCommand, "BargainDepartmentId", DbType.Guid, model.BargainDepartmentId);
            db.AddInParameter(dbCommand, "BargainDepartmentName", DbType.AnsiString, model.BargainDepartmentName);
            db.AddInParameter(dbCommand, "BargainUserId", DbType.Guid, model.BargainUserId);
            db.AddInParameter(dbCommand, "BargainUserName", DbType.AnsiString, model.BargainUserName);
            db.AddInParameter(dbCommand, "VenderCityId", DbType.Guid, model.VenderCityId);
            db.AddInParameter(dbCommand, "VenderCityName", DbType.AnsiString, model.VenderCityName);
            db.AddInParameter(dbCommand, "VenderCompanyId", DbType.Guid, model.VenderCompanyId);
            db.AddInParameter(dbCommand, "VenderCompanyName", DbType.AnsiString, model.VenderCompanyName);
            db.AddInParameter(dbCommand, "VenderDepartId", DbType.Guid, model.VenderDepartId);
            db.AddInParameter(dbCommand, "VenderDepartName", DbType.AnsiString, model.VenderDepartName);
            db.AddInParameter(dbCommand, "VenderUserId", DbType.Guid, model.VenderUserId);
            db.AddInParameter(dbCommand, "VenderUserName", DbType.AnsiString, model.VenderUserName);
            db.AddInParameter(dbCommand, "VenderId", DbType.Guid, model.VenderId);
            db.AddInParameter(dbCommand, "VenderName", DbType.AnsiString, model.VenderName);
            db.AddInParameter(dbCommand, "VenderNo", DbType.AnsiString, model.VenderNo);
            db.AddInParameter(dbCommand, "VenderPhone", DbType.AnsiString, model.VenderPhone);
            db.AddInParameter(dbCommand, "VenderMobile", DbType.AnsiString, model.VenderMobile);
            db.AddInParameter(dbCommand, "BuyerCityId", DbType.Guid, model.BuyerCityId);
            db.AddInParameter(dbCommand, "BuyerCityName", DbType.AnsiString, model.BuyerCityName);
            db.AddInParameter(dbCommand, "BuyerCompanyId", DbType.Guid, model.BuyerCompanyId);
            db.AddInParameter(dbCommand, "BuyerCompanyName", DbType.AnsiString, model.BuyerCompanyName);
            db.AddInParameter(dbCommand, "BuyerDepartId", DbType.Guid, model.BuyerDepartId);
            db.AddInParameter(dbCommand, "BuyerDepartName", DbType.AnsiString, model.BuyerDepartName);
            db.AddInParameter(dbCommand, "BuyerUserId", DbType.Guid, model.BuyerUserId);
            db.AddInParameter(dbCommand, "BuyerUserName", DbType.AnsiString, model.BuyerUserName);
            db.AddInParameter(dbCommand, "BuyerId", DbType.Guid, model.BuyerId);
            db.AddInParameter(dbCommand, "BuyerName", DbType.AnsiString, model.BuyerName);
            db.AddInParameter(dbCommand, "BuyerNo", DbType.AnsiString, model.BuyerNo);
            db.AddInParameter(dbCommand, "BuyerPhone", DbType.AnsiString, model.BuyerPhone);
            db.AddInParameter(dbCommand, "BuyerMobile", DbType.AnsiString, model.BuyerMobile);
            db.AddInParameter(dbCommand, "VStanCommision", DbType.Decimal, model.VStanCommision);
            db.AddInParameter(dbCommand, "BStanCommision", DbType.Decimal, model.BStanCommision);
            db.AddInParameter(dbCommand, "VRealCommision", DbType.Decimal, model.VRealCommision);
            db.AddInParameter(dbCommand, "BRealCommision", DbType.Decimal, model.BRealCommision);
            db.AddInParameter(dbCommand, "VCommision", DbType.Decimal, model.VCommision);
            db.AddInParameter(dbCommand, "BCommision", DbType.Decimal, model.BCommision);
            db.AddInParameter(dbCommand, "VConsulting", DbType.Decimal, model.VConsulting);
            db.AddInParameter(dbCommand, "BConsulting", DbType.Decimal, model.BConsulting);
            db.AddInParameter(dbCommand, "AppEmployeeId", DbType.Guid, model.AppEmployeeId);
            db.AddInParameter(dbCommand, "AppEmployee", DbType.AnsiString, model.AppEmployee);
            db.AddInParameter(dbCommand, "AppDepartId", DbType.Guid, model.AppDepartId);
            db.AddInParameter(dbCommand, "AppDepart", DbType.AnsiString, model.AppDepart);
            db.AddInParameter(dbCommand, "AppCompanyId", DbType.Guid, model.AppCompanyId);
            db.AddInParameter(dbCommand, "AppCompany", DbType.AnsiString, model.AppCompany);
            db.AddInParameter(dbCommand, "AppCityId", DbType.Guid, model.AppCityId);
            db.AddInParameter(dbCommand, "AppCity", DbType.AnsiString, model.AppCity);
            db.AddInParameter(dbCommand, "ConfirmEmplyeeId", DbType.Guid, model.ConfirmEmplyeeId);
            db.AddInParameter(dbCommand, "ConfirmEmplyee", DbType.AnsiString, model.ConfirmEmplyee);
            db.AddInParameter(dbCommand, "ConfirmDepartId", DbType.Guid, model.ConfirmDepartId);
            db.AddInParameter(dbCommand, "ConfirmDepart", DbType.AnsiString, model.ConfirmDepart);
            db.AddInParameter(dbCommand, "ConfirmCompanyId", DbType.Guid, model.ConfirmCompanyId);
            db.AddInParameter(dbCommand, "ConfirmCompany", DbType.AnsiString, model.ConfirmCompany);
            db.AddInParameter(dbCommand, "ConfirmCityId", DbType.Guid, model.ConfirmCityId);
            db.AddInParameter(dbCommand, "ConfirmCity", DbType.AnsiString, model.ConfirmCity);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, model.AddTime);
            db.AddInParameter(dbCommand, "UpdateCityId", DbType.Guid, model.UpdateCityId);
            db.AddInParameter(dbCommand, "UpdateCityName", DbType.AnsiString, model.UpdateCityName);
            db.AddInParameter(dbCommand, "UpdateCompanyId", DbType.Guid, model.UpdateCompanyId);
            db.AddInParameter(dbCommand, "UpdateCompanyName", DbType.AnsiString, model.UpdateCompanyName);
            db.AddInParameter(dbCommand, "UpdateDepartmentId", DbType.Guid, model.UpdateDepartmentId);
            db.AddInParameter(dbCommand, "UpdateDepartmentName", DbType.AnsiString, model.UpdateDepartmentName);
            db.AddInParameter(dbCommand, "UpdateUserId", DbType.Guid, model.UpdateUserId);
            db.AddInParameter(dbCommand, "UpdateUserName", DbType.AnsiString, model.UpdateUserName);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime, model.UpdateTime);
            db.AddInParameter(dbCommand, "bArchivement", DbType.Boolean, model.bArchivement);
            db.AddInParameter(dbCommand, "ArchivementDate", DbType.DateTime, model.ArchivementDate);
            db.AddInParameter(dbCommand, "ArchivementYear", DbType.Int32, model.ArchivementYear);
            db.AddInParameter(dbCommand, "ArchivementMonth", DbType.Int32, model.ArchivementMonth);
            db.AddInParameter(dbCommand, "LastCreateArchDate", DbType.DateTime, model.LastCreateArchDate);
            db.AddInParameter(dbCommand, "CreateArchEmpId", DbType.Guid, model.CreateArchEmpId);
            db.AddInParameter(dbCommand, "CreateArchEmp", DbType.AnsiString, model.CreateArchEmp);
            db.AddInParameter(dbCommand, "CreateArchDepartId", DbType.Guid, model.CreateArchDepartId);
            db.AddInParameter(dbCommand, "CreateArchDepart", DbType.AnsiString, model.CreateArchDepart);
            db.AddInParameter(dbCommand, "LockStatus", DbType.Int32, model.LockStatus);
            db.AddInParameter(dbCommand, "Status", DbType.Int32, model.Status);
            db.AddInParameter(dbCommand, "PointRemark", DbType.AnsiString, model.PointRemark);
            db.AddInParameter(dbCommand, "ContractCityId", DbType.Guid, model.ContractCityId);
            db.AddInParameter(dbCommand, "ContractCityName", DbType.AnsiString, model.ContractCityName);
            db.AddInParameter(dbCommand, "ContractCompanyId", DbType.Guid, model.ContractCompanyId);
            db.AddInParameter(dbCommand, "ContractCompanyName", DbType.AnsiString, model.ContractCompanyName);
            db.AddInParameter(dbCommand, "ContractDepartmentId", DbType.Guid, model.ContractDepartmentId);
            db.AddInParameter(dbCommand, "ContractDepartmentName", DbType.AnsiString, model.ContractDepartmentName);
            db.AddInParameter(dbCommand, "ContractUserId", DbType.Guid, model.ContractUserId);
            db.AddInParameter(dbCommand, "ContractUserName", DbType.AnsiString, model.ContractUserName);
            db.AddInParameter(dbCommand, "CompleteYear", DbType.AnsiString, model.CompleteYear);
            db.AddInParameter(dbCommand, "Fitment", DbType.AnsiString, model.Fitment);
            db.AddInParameter(dbCommand, "LitigationStatus", DbType.Int32, model.LitigationStatus);
            db.AddInParameter(dbCommand, "HasFollow", DbType.Boolean, model.HasFollow);
            db.AddInParameter(dbCommand, "CustomerSource", DbType.AnsiString, model.CustomerSource);
            db.AddInParameter(dbCommand, "VSTDiscount", DbType.Decimal, model.VSTDiscount);
            db.AddInParameter(dbCommand, "BSTDiscount", DbType.Decimal, model.BSTDiscount);
            db.AddInParameter(dbCommand, "STMemo", DbType.AnsiString, model.STMemo);
            db.AddInParameter(dbCommand, "FixDiscount", DbType.Decimal, model.FixDiscount);
            db.AddInParameter(dbCommand, "DiscountRate", DbType.Decimal, model.DiscountRate);
            db.AddInParameter(dbCommand, "RateDate", DbType.DateTime, model.RateDate);
            db.AddInParameter(dbCommand, "HasOver", DbType.Boolean, model.HasOver);
            db.AddInParameter(dbCommand, "OverName", DbType.AnsiString, model.OverName);
            db.AddInParameter(dbCommand, "OverTime", DbType.DateTime, model.OverTime);
            db.ExecuteNonQuery(dbCommand);

        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public static void Delete(Guid ContractId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from t_Contract_BaseInfo ");
            strSql.Append(" where ContractId=@ContractId ");
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ContractId", DbType.Guid, ContractId);
            db.ExecuteNonQuery(dbCommand);

        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Chenxin.Lib.Business.Entity.t_Contract_BaseInfo GetModel(Guid ContractId)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ContractId,ApplyId,ContractCode,ContractDate,BusinessDescribe,BusinessType,BargainType,BargainUnitPrice,BargainPrice,HouseId,HouseCode,HouseAddress,Area,CompleteYear,Fitment,CommunityId,Community,CommunityAddress,PropertyCode,Region,Block,CurrentFloor,TotalFloor,BuildingType,HouseUse,HouseType,BargainCityId,BargainCityName,BargainCompanyId,BargainCompanyName,BargainDepartmentId,BargainDepartmentName,BargainUserId,BargainUserName,VenderCityId,VenderCityName,VenderCompanyId,VenderCompanyName,VenderDepartId,VenderDepartName,VenderUserId,VenderUserName,VenderId,VenderName,VenderNo,VenderPhone,VenderMobile,BuyerCityId,BuyerCityName,BuyerCompanyId,BuyerCompanyName,BuyerDepartId,BuyerDepartName,BuyerUserId,BuyerUserName,BuyerId,BuyerName,BuyerNo,BuyerPhone,BuyerMobile,VStanCommision,BStanCommision,VRealCommision,BRealCommision,VCommision,BCommision,VConsulting,BConsulting,AppEmployeeId,AppEmployee,AppDepartId,AppDepart,AppCompanyId,AppCompany,AppCityId,AppCity,ConfirmEmplyeeId,ConfirmEmplyee,ConfirmDepartId,ConfirmDepart,ConfirmCompanyId,ConfirmCompany,ConfirmCityId,ConfirmCity,AddTime,UpdateCityId,UpdateCityName,UpdateCompanyId,UpdateCompanyName,UpdateDepartmentId,UpdateDepartmentName,UpdateUserId,UpdateUserName,UpdateTime,bArchivement,ArchivementDate,ArchivementYear,ArchivementMonth,LastCreateArchDate,CreateArchEmpId,CreateArchEmp,CreateArchDepartId,CreateArchDepart,LockStatus,Status,PointRemark,ContractCityId,ContractCityName,ContractCompanyId,ContractCompanyName,ContractDepartmentId,ContractDepartmentName,ContractUserId,ContractUserName,LitigationStatus,HasFollow,HouseProperty,CustomerSource,VSTDiscount,BSTDiscount,STMemo,FixDiscount,DiscountRate,RateDate,HasOver,OverName,OverTime from t_Contract_BaseInfo ");
            strSql.Append(" where ContractId=@ContractId ");
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business_Search");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ContractId", DbType.Guid, ContractId);
            Chenxin.Lib.Business.Entity.t_Contract_BaseInfo model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                dataReader.Close();
                dataReader.Dispose();
            }
            return model;
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Chenxin.Lib.Business.Entity.t_Contract_BaseInfo GetModelByCode(string ContractCode)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ContractId,ApplyId,ContractCode,ContractDate,BusinessDescribe,BusinessType,BargainType,BargainUnitPrice,BargainPrice,HouseId,HouseCode,HouseAddress,Area,CompleteYear,Fitment,CommunityId,Community,CommunityAddress,PropertyCode,Region,Block,CurrentFloor,TotalFloor,BuildingType,HouseUse,HouseType,BargainCityId,BargainCityName,BargainCompanyId,BargainCompanyName,BargainDepartmentId,BargainDepartmentName,BargainUserId,BargainUserName,VenderCityId,VenderCityName,VenderCompanyId,VenderCompanyName,VenderDepartId,VenderDepartName,VenderUserId,VenderUserName,VenderId,VenderName,VenderNo,VenderPhone,VenderMobile,BuyerCityId,BuyerCityName,BuyerCompanyId,BuyerCompanyName,BuyerDepartId,BuyerDepartName,BuyerUserId,BuyerUserName,BuyerId,BuyerName,BuyerNo,BuyerPhone,BuyerMobile,VStanCommision,BStanCommision,VRealCommision,BRealCommision,VCommision,BCommision,VConsulting,BConsulting,AppEmployeeId,AppEmployee,AppDepartId,AppDepart,AppCompanyId,AppCompany,AppCityId,AppCity,ConfirmEmplyeeId,ConfirmEmplyee,ConfirmDepartId,ConfirmDepart,ConfirmCompanyId,ConfirmCompany,ConfirmCityId,ConfirmCity,AddTime,UpdateCityId,UpdateCityName,UpdateCompanyId,UpdateCompanyName,UpdateDepartmentId,UpdateDepartmentName,UpdateUserId,UpdateUserName,UpdateTime,bArchivement,ArchivementDate,ArchivementYear,ArchivementMonth,LastCreateArchDate,CreateArchEmpId,CreateArchEmp,CreateArchDepartId,CreateArchDepart,LockStatus,Status,PointRemark,ContractCityId,ContractCityName,ContractCompanyId,ContractCompanyName,ContractDepartmentId,ContractDepartmentName,ContractUserId,ContractUserName,LitigationStatus,HasFollow,HouseProperty,CustomerSource,VSTDiscount,BSTDiscount,STMemo,FixDiscount,DiscountRate,RateDate,HasOver,OverName,OverTime from t_Contract_BaseInfo ");
            strSql.Append(" where ContractCode=@ContractCode ");
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business_Search");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ContractCode", DbType.AnsiString, ContractCode);
            Chenxin.Lib.Business.Entity.t_Contract_BaseInfo model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                dataReader.Close();
                dataReader.Dispose();
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ContractId,ApplyId,ContractCode,ContractDate,BusinessDescribe,BusinessType,BargainType,BargainUnitPrice,BargainPrice,HouseId,HouseCode,HouseAddress,Area,CompleteYear,Fitment,CommunityId,Community,CommunityAddress,PropertyCode,Region,Block,CurrentFloor,TotalFloor,BuildingType,HouseUse,HouseType,BargainCityId,BargainCityName,BargainCompanyId,BargainCompanyName,BargainDepartmentId,BargainDepartmentName,BargainUserId,BargainUserName,VenderCityId,VenderCityName,VenderCompanyId,VenderCompanyName,VenderDepartId,VenderDepartName,VenderUserId,VenderUserName,VenderId,VenderName,VenderNo,VenderPhone,VenderMobile,BuyerCityId,BuyerCityName,BuyerCompanyId,BuyerCompanyName,BuyerDepartId,BuyerDepartName,BuyerUserId,BuyerUserName,BuyerId,BuyerName,BuyerNo,BuyerPhone,BuyerMobile,VStanCommision,BStanCommision,VRealCommision,BRealCommision,VCommision,BCommision,VConsulting,BConsulting,AppEmployeeId,AppEmployee,AppDepartId,AppDepart,AppCompanyId,AppCompany,AppCityId,AppCity,ConfirmEmplyeeId,ConfirmEmplyee,ConfirmDepartId,ConfirmDepart,ConfirmCompanyId,ConfirmCompany,ConfirmCityId,ConfirmCity,AddTime,UpdateCityId,UpdateCityName,UpdateCompanyId,UpdateCompanyName,UpdateDepartmentId,UpdateDepartmentName,UpdateUserId,UpdateUserName,UpdateTime,bArchivement,ArchivementDate,ArchivementYear,ArchivementMonth,LastCreateArchDate,CreateArchEmpId,CreateArchEmp,CreateArchDepartId,CreateArchDepart,LockStatus,Status,PointRemark,ContractCityId,ContractCityName,ContractCompanyId,ContractCompanyName,ContractDepartmentId,ContractDepartmentName,ContractUserId,ContractUserName,LitigationStatus,HouseProperty,HasFollow,CustomerSource,VSTDiscount,BSTDiscount,STMemo,FixDiscount,DiscountRate,RateDate,HasOver,OverName,OverTime ");
            strSql.Append(" FROM t_Contract_BaseInfo ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business_Search");
            return db.ExecuteDataSet(CommandType.Text, strSql.ToString());
        }


        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public static DataSet GetList(int PageIndex, int PageSize, String OrderField, string TableName, string StrWhere, string FieldList, string TableFieldList, bool DoCount)
        {
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business_Search");
            DbCommand dbCommand = db.GetStoredProcCommand("PagerMultiTable");
            db.AddInParameter(dbCommand, "PageIndex", DbType.Int32, PageIndex);
            db.AddInParameter(dbCommand, "PageSize", DbType.Int32, PageSize);
            db.AddInParameter(dbCommand, "OrderField", DbType.AnsiString, OrderField);
            db.AddInParameter(dbCommand, "TableName", DbType.AnsiString, TableName);
            db.AddInParameter(dbCommand, "StrWhere", DbType.AnsiString, StrWhere);
            db.AddInParameter(dbCommand, "FieldList", DbType.AnsiString, FieldList);
            db.AddInParameter(dbCommand, "TableFieldList", DbType.AnsiString, TableFieldList);
            db.AddInParameter(dbCommand, "DoCount", DbType.Boolean, DoCount);
            return db.ExecuteDataSet(dbCommand);
        }

        /// <summary>
        /// 获得数据列表（比DataSet效率高，推荐使用）
        /// </summary>
        public static List<Chenxin.Lib.Business.Entity.t_Contract_BaseInfo> GetListArray(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ContractId,ApplyId,ContractCode,ContractDate,BusinessDescribe,BusinessType,BargainType,BargainUnitPrice,BargainPrice,HouseId,HouseCode,HouseAddress,Area,CompleteYear,Fitment,CommunityId,Community,CommunityAddress,PropertyCode,Region,Block,CurrentFloor,TotalFloor,BuildingType,HouseUse,HouseType,BargainCityId,BargainCityName,BargainCompanyId,BargainCompanyName,BargainDepartmentId,BargainDepartmentName,BargainUserId,BargainUserName,VenderCityId,VenderCityName,VenderCompanyId,VenderCompanyName,VenderDepartId,VenderDepartName,VenderUserId,VenderUserName,VenderId,VenderName,VenderNo,VenderPhone,VenderMobile,BuyerCityId,BuyerCityName,BuyerCompanyId,BuyerCompanyName,BuyerDepartId,BuyerDepartName,BuyerUserId,BuyerUserName,BuyerId,BuyerName,BuyerNo,BuyerPhone,BuyerMobile,VStanCommision,BStanCommision,VRealCommision,BRealCommision,VCommision,BCommision,VConsulting,BConsulting,AppEmployeeId,AppEmployee,AppDepartId,AppDepart,AppCompanyId,AppCompany,AppCityId,AppCity,ConfirmEmplyeeId,ConfirmEmplyee,ConfirmDepartId,ConfirmDepart,ConfirmCompanyId,ConfirmCompany,ConfirmCityId,ConfirmCity,AddTime,UpdateCityId,UpdateCityName,UpdateCompanyId,UpdateCompanyName,UpdateDepartmentId,UpdateDepartmentName,UpdateUserId,UpdateUserName,UpdateTime,bArchivement,ArchivementDate,ArchivementYear,ArchivementMonth,LastCreateArchDate,CreateArchEmpId,CreateArchEmp,CreateArchDepartId,CreateArchDepart,LockStatus,Status,PointRemark,ContractCityId,ContractCityName,ContractCompanyId,ContractCompanyName,ContractDepartmentId,ContractDepartmentName,ContractUserId,ContractUserName,LitigationStatus,HasFollow,HouseProperty,CustomerSource,VSTDiscount,BSTDiscount,STMemo,FixDiscount,DiscountRate,RateDate,HasOver,OverName,OverTime ");
            strSql.Append(" FROM t_Contract_BaseInfo ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<Chenxin.Lib.Business.Entity.t_Contract_BaseInfo> list = new List<Chenxin.Lib.Business.Entity.t_Contract_BaseInfo>();
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business_Search");
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
                while (dataReader.Read())
                {
                    list.Add(ReaderBind(dataReader));
                }
                dataReader.Close();
                dataReader.Dispose();
            }
            return list;
        }


        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public static Chenxin.Lib.Business.Entity.t_Contract_BaseInfo ReaderBind(IDataReader dataReader)
        {
            Chenxin.Lib.Business.Entity.t_Contract_BaseInfo model = new Chenxin.Lib.Business.Entity.t_Contract_BaseInfo();
            object ojb;
            ojb = dataReader["ContractId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ContractId = new Guid(ojb.ToString());
            }
            ojb = dataReader["ApplyId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ApplyId = new Guid(ojb.ToString());
            }
            model.ContractCode = dataReader["ContractCode"].ToString();
            ojb = dataReader["ContractDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ContractDate = (DateTime)ojb;
            }
            model.BusinessDescribe = dataReader["BusinessDescribe"].ToString();
            ojb = dataReader["BusinessType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BusinessType = (int)ojb;
            }
            ojb = dataReader["BargainType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BargainType = (int)ojb;
            }
            ojb = dataReader["BargainUnitPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BargainUnitPrice = (decimal)ojb;
            }
            ojb = dataReader["BargainPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BargainPrice = (decimal)ojb;
            }
            ojb = dataReader["HouseId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.HouseId = new Guid(ojb.ToString());
            }
            model.HouseCode = dataReader["HouseCode"].ToString();
            model.HouseAddress = dataReader["HouseAddress"].ToString();
            ojb = dataReader["Area"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Area = (decimal)ojb;
            }
            model.CompleteYear = dataReader["CompleteYear"].ToString();
            model.Fitment = dataReader["Fitment"].ToString();
            ojb = dataReader["CommunityId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CommunityId = new Guid(ojb.ToString());
            }
            model.Community = dataReader["Community"].ToString();
            model.CommunityAddress = dataReader["CommunityAddress"].ToString();
            model.PropertyCode = dataReader["PropertyCode"].ToString();
            model.Region = dataReader["Region"].ToString();
            model.Block = dataReader["Block"].ToString();
            ojb = dataReader["CurrentFloor"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CurrentFloor = (int)ojb;
            }
            ojb = dataReader["TotalFloor"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TotalFloor = (int)ojb;
            }
            model.BuildingType = dataReader["BuildingType"].ToString();
            model.HouseUse = dataReader["HouseUse"].ToString();
            model.HouseType = dataReader["HouseType"].ToString();
            ojb = dataReader["BargainCityId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BargainCityId = new Guid(ojb.ToString());
            }
            model.BargainCityName = dataReader["BargainCityName"].ToString();
            ojb = dataReader["BargainCompanyId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BargainCompanyId = new Guid(ojb.ToString());
            }
            model.BargainCompanyName = dataReader["BargainCompanyName"].ToString();
            ojb = dataReader["BargainDepartmentId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BargainDepartmentId = new Guid(ojb.ToString());
            }
            model.BargainDepartmentName = dataReader["BargainDepartmentName"].ToString();
            ojb = dataReader["BargainUserId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BargainUserId = new Guid(ojb.ToString());
            }
            model.BargainUserName = dataReader["BargainUserName"].ToString();
            ojb = dataReader["VenderCityId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VenderCityId = new Guid(ojb.ToString());
            }
            model.VenderCityName = dataReader["VenderCityName"].ToString();
            ojb = dataReader["VenderCompanyId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VenderCompanyId = new Guid(ojb.ToString());
            }
            model.VenderCompanyName = dataReader["VenderCompanyName"].ToString();
            ojb = dataReader["VenderDepartId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VenderDepartId = new Guid(ojb.ToString());
            }
            model.VenderDepartName = dataReader["VenderDepartName"].ToString();
            ojb = dataReader["VenderUserId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VenderUserId = new Guid(ojb.ToString());
            }
            model.VenderUserName = dataReader["VenderUserName"].ToString();
            ojb = dataReader["VenderId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VenderId = new Guid(ojb.ToString());
            }
            model.VenderName = dataReader["VenderName"].ToString();
            model.VenderNo = dataReader["VenderNo"].ToString();
            model.VenderPhone = dataReader["VenderPhone"].ToString();
            model.VenderMobile = dataReader["VenderMobile"].ToString();
            ojb = dataReader["BuyerCityId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BuyerCityId = new Guid(ojb.ToString());
            }
            model.BuyerCityName = dataReader["BuyerCityName"].ToString();
            ojb = dataReader["BuyerCompanyId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BuyerCompanyId = new Guid(ojb.ToString());
            }
            model.BuyerCompanyName = dataReader["BuyerCompanyName"].ToString();
            ojb = dataReader["BuyerDepartId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BuyerDepartId = new Guid(ojb.ToString());
            }
            model.BuyerDepartName = dataReader["BuyerDepartName"].ToString();
            ojb = dataReader["BuyerUserId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BuyerUserId = new Guid(ojb.ToString());
            }
            model.BuyerUserName = dataReader["BuyerUserName"].ToString();
            ojb = dataReader["BuyerId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BuyerId = new Guid(ojb.ToString());
            }
            model.BuyerName = dataReader["BuyerName"].ToString();
            model.BuyerNo = dataReader["BuyerNo"].ToString();
            model.BuyerPhone = dataReader["BuyerPhone"].ToString();
            model.BuyerMobile = dataReader["BuyerMobile"].ToString();
            ojb = dataReader["VStanCommision"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VStanCommision = (decimal)ojb;
            }
            ojb = dataReader["BStanCommision"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BStanCommision = (decimal)ojb;
            }
            ojb = dataReader["VRealCommision"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VRealCommision = (decimal)ojb;
            }
            ojb = dataReader["BRealCommision"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BRealCommision = (decimal)ojb;
            }
            ojb = dataReader["VCommision"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VCommision = (decimal)ojb;
            }
            ojb = dataReader["BCommision"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BCommision = (decimal)ojb;
            }
            ojb = dataReader["VConsulting"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VConsulting = (decimal)ojb;
            }
            ojb = dataReader["BConsulting"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BConsulting = (decimal)ojb;
            }
            ojb = dataReader["AppEmployeeId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AppEmployeeId = new Guid(ojb.ToString());
            }
            model.AppEmployee = dataReader["AppEmployee"].ToString();
            ojb = dataReader["AppDepartId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AppDepartId = new Guid(ojb.ToString());
            }
            model.AppDepart = dataReader["AppDepart"].ToString();
            ojb = dataReader["AppCompanyId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AppCompanyId = new Guid(ojb.ToString());
            }
            model.AppCompany = dataReader["AppCompany"].ToString();
            ojb = dataReader["AppCityId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AppCityId = new Guid(ojb.ToString());
            }
            model.AppCity = dataReader["AppCity"].ToString();
            ojb = dataReader["ConfirmEmplyeeId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ConfirmEmplyeeId = new Guid(ojb.ToString());
            }
            model.ConfirmEmplyee = dataReader["ConfirmEmplyee"].ToString();
            ojb = dataReader["ConfirmDepartId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ConfirmDepartId = new Guid(ojb.ToString());
            }
            model.ConfirmDepart = dataReader["ConfirmDepart"].ToString();
            ojb = dataReader["ConfirmCompanyId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ConfirmCompanyId = new Guid(ojb.ToString());
            }
            model.ConfirmCompany = dataReader["ConfirmCompany"].ToString();
            ojb = dataReader["ConfirmCityId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ConfirmCityId = new Guid(ojb.ToString());
            }
            model.ConfirmCity = dataReader["ConfirmCity"].ToString();
            ojb = dataReader["AddTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AddTime = (DateTime)ojb;
            }
            ojb = dataReader["UpdateCityId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UpdateCityId = new Guid(ojb.ToString());
            }
            model.UpdateCityName = dataReader["UpdateCityName"].ToString();
            ojb = dataReader["UpdateCompanyId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UpdateCompanyId = new Guid(ojb.ToString());
            }
            model.UpdateCompanyName = dataReader["UpdateCompanyName"].ToString();
            ojb = dataReader["UpdateDepartmentId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UpdateDepartmentId = new Guid(ojb.ToString());
            }
            model.UpdateDepartmentName = dataReader["UpdateDepartmentName"].ToString();
            ojb = dataReader["UpdateUserId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UpdateUserId = new Guid(ojb.ToString());
            }
            model.UpdateUserName = dataReader["UpdateUserName"].ToString();
            ojb = dataReader["UpdateTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UpdateTime = (DateTime)ojb;
            }
            ojb = dataReader["bArchivement"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.bArchivement = (bool)ojb;
            }
            ojb = dataReader["ArchivementDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ArchivementDate = (DateTime)ojb;
            }
            ojb = dataReader["ArchivementYear"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ArchivementYear = (int)ojb;
            }
            ojb = dataReader["ArchivementMonth"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ArchivementMonth = (int)ojb;
            }
            ojb = dataReader["LastCreateArchDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.LastCreateArchDate = (DateTime)ojb;
            }
            ojb = dataReader["CreateArchEmpId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateArchEmpId = new Guid(ojb.ToString());
            }
            model.CreateArchEmp = dataReader["CreateArchEmp"].ToString();
            ojb = dataReader["CreateArchDepartId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateArchDepartId = new Guid(ojb.ToString());
            }
            model.CreateArchDepart = dataReader["CreateArchDepart"].ToString();
            ojb = dataReader["LockStatus"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.LockStatus = (int)ojb;
            }
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = (int)ojb;
            }
            model.PointRemark = dataReader["PointRemark"].ToString();
            ojb = dataReader["ContractCityId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ContractCityId = new Guid(ojb.ToString());
            }
            model.ContractCityName = dataReader["ContractCityName"].ToString();
            ojb = dataReader["ContractCompanyId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ContractCompanyId = new Guid(ojb.ToString());
            }
            model.ContractCompanyName = dataReader["ContractCompanyName"].ToString();
            ojb = dataReader["ContractDepartmentId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ContractDepartmentId = new Guid(ojb.ToString());
            }
            model.ContractDepartmentName = dataReader["ContractDepartmentName"].ToString();
            ojb = dataReader["ContractUserId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ContractUserId = new Guid(ojb.ToString());
            }
            model.ContractUserName = dataReader["ContractUserName"].ToString();
            ojb = dataReader["LitigationStatus"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.LitigationStatus = (int)ojb;
            }
            ojb = dataReader["HasFollow"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.HasFollow = (bool)ojb;
            }
            ojb = dataReader["HouseProperty"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.HouseProperty = (int)ojb;
            }
            model.CustomerSource = dataReader["CustomerSource"].ToString();
            ojb = dataReader["VSTDiscount"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.VSTDiscount = (decimal)ojb;
            }
            ojb = dataReader["BSTDiscount"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BSTDiscount = (decimal)ojb;
            }
            model.STMemo = dataReader["STMemo"].ToString();
            ojb = dataReader["FixDiscount"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FixDiscount = (decimal)ojb;
            }
            ojb = dataReader["DiscountRate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.DiscountRate = (decimal)ojb;
            }
            ojb = dataReader["RateDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RateDate = (DateTime)ojb;
            }
            ojb = dataReader["HasOver"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.HasOver = (bool)ojb;
            }
            model.OverName = dataReader["OverName"].ToString();
            ojb = dataReader["OverTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.OverTime = (DateTime)ojb;
            }
            return model;
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public static DataSet GetPartList(int PageIndex, int PageSize, String OrderField, string TableName, string StrWhere, string GroupList, string FieldList, string TableFieldList, bool DoCount)
        {
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business_Search");
            DbCommand dbCommand = db.GetStoredProcCommand("PagerMultiTableGroup");
            db.AddInParameter(dbCommand, "PageIndex", DbType.Int32, PageIndex);
            db.AddInParameter(dbCommand, "PageSize", DbType.Int32, PageSize);
            db.AddInParameter(dbCommand, "OrderField", DbType.AnsiString, OrderField);
            db.AddInParameter(dbCommand, "TableName", DbType.AnsiString, TableName);
            db.AddInParameter(dbCommand, "StrWhere", DbType.AnsiString, StrWhere);
            db.AddInParameter(dbCommand, "GroupList", DbType.AnsiString, GroupList);
            db.AddInParameter(dbCommand, "FieldList", DbType.AnsiString, FieldList);
            db.AddInParameter(dbCommand, "TableFieldList", DbType.AnsiString, TableFieldList);
            db.AddInParameter(dbCommand, "DoCount", DbType.Boolean, DoCount);
            return db.ExecuteDataSet(dbCommand);
        }

        /// <summary>
        /// 更新诉讼状态
        /// </summary>
        /// <param name="modelId">记录的ModelId</param>
        public static void ChangeStatus(string ContractCode, int status)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update t_Contract_BaseInfo set ");
            strSql.Append("LitigationStatus=@LitigationStatus");
            strSql.Append(" where ContractCode=@ContractCode ");

            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            #region 参数
            db.AddInParameter(dbCommand, "@ContractCode", DbType.AnsiString, ContractCode);
            db.AddInParameter(dbCommand, "@LitigationStatus", DbType.Int32, status);
            #endregion

            db.ExecuteNonQuery(dbCommand);
        }


        public static void CaculateFinanceDeductInfo(Guid contractId)
        {
            Database db = DatabaseFactory.CreateDatabase("Chenxin_Business");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_ExcuteContractFinancInfoExt");
            db.AddInParameter(dbCommand, "contractId", DbType.Guid, contractId);
            
            db.ExecuteNonQuery(dbCommand);
        }
        #endregion  成员方法
    }
}

